import api from 'src-api'
import * as types from '../types'
// import { excuteAjax } from '../tool'

const actions = {

  [types.TOAST_SHOW] (context, payload) {
    context.commit(types.TOAST_SHOW)
  },

  [types.TOAST_HIDE] (context, payload) {
    context.commit(types.TOAST_HIDE)
  },

  [types.MODAL_SHOW] (context, payload) {
    context.commit(types.MODAL_SHOW)
  },

  [types.MODAL_HIDE] (context, payload) {
    context.commit(types.MODAL_HIDE)
  },

  [types.LOADING_SHOW] (context, payload) {
    context.commit(types.LOADING_SHOW)
  },

  [types.LOADING_HIDE] (context, payload) {
    context.commit(types.LOADING_HIDE)
  },

  [types.FETCH_SITE] (context, payload) {
    return api.userApi.profile(payload).then(res => {
      context.commit(types.FETCH_SITE, res.data)
      return res.data
    })
    // return excuteAjax(context, payload, api.userApi.profile, types.FETCH_SITE)
  },
}

export default actions
